<template>
    <div>
      <div class="mui-numbox" data-numbox-min='1' :data-numbox-max='max'>
        <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
        <input id="test" class="mui-input-numbox" type="number" 
          :value="initCount" ref="num" @change="countChanged" />
        <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
      </div>
    </div>
  </template>
  
  <script>
  import mui from '../lib/MUI/js/mui.min.js'
  export default {
      props:['max','initCount','goodsid'],
    data() {
      return {
  
      };
    },
    created() {},
    mounted(){
        mui('.mui-numbox').numbox()
    },
    methods: {
        countChanged(){
            const count =parseInt(this.$refs.num.value)
            this.$emit('count',{count:count,id:this.goodsid})
        }
    },
    computed: {},
    watch:{
        max(newVal){
            mui('.mui-numbox').numbox().setOption('max',newVal)
        }
    }
    
  }
  </script>
  
  <style scoped>
  </style>